-
Notifications
You must be signed in to change notification settings - Fork 383
Add level down support #2492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add level down support #2492
Conversation
| public readonly LocalizedString Left = @"{00} has left {01}."; | ||
|
|
||
| [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] | ||
| public readonly LocalizedString LevelDown = @"You have leveled down! You are now level {00}!"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't super natural in english, it would be better to say You have lost a level! You are now level {00}!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also change the name of the string to LevelLost
| else | ||
| { | ||
| var levelCount = 0; | ||
| while (Exp < 0 && Level - levelCount > 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ levelCount
| Exp += GetExperienceToNextLevel(Level - levelCount - 1); | ||
| levelCount++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Swap these
First line should be --levelCount; this takes into account that - 1 implicitly
Second line should be Exp += GetExperienceToNextLevel(Level + levelCount);
| } | ||
|
|
||
| PacketSender.SendExperience(this); | ||
| AddLevels(-levelCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AddLevels(levelCount);
With the negative counting there's no reason to flip the sign.
| if (Exp < 0) | ||
| { | ||
| Exp = 0; | ||
| PacketSender.SendExperience(this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be outside of the if so that the changed EXP is sent above level 1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any exp for any other level is sent at the end of AddLevels()
I added this if because, when I went down a level and was at level 1, after AddLevels() was executed, the exp would become negative if I removed more than I had
So I added this if as "if after removing the player's levels, the exp remains negative, reset and send"
the exp will never be negative after AddLevels(), if when the function finishes its level is above 1
It only happened exclusively in this situation, because the exp is not reset when leveling down, and it does not reset when it is negative when the player is at level 1.
| Name | ||
| ); | ||
|
|
||
| if (ClassBase.TryGet(ClassId, out var classDescriptor) && classDescriptor?.Spells != default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put ClassBase? classDescriptor = null; before if (levels > 0)
Here, change the if to if ((classDescriptor?.Id == ClassId || ClassBase.TryGet(ClassId, out classDescriptor)) && classDescriptor?.Spells != default)
| Name | ||
| ); | ||
|
|
||
| if (ClassBase.TryGet(ClassId, out var classDescriptor) && classDescriptor?.Spells != default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, change the if to if ((classDescriptor?.Id == ClassId || ClassBase.TryGet(ClassId, out classDescriptor)) && classDescriptor?.Spells != default)
| } | ||
|
|
||
| public void TakeExperience(long amount) | ||
| public void TakeExperience(long amount, bool enableLevelDown = false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add , bool force = false as the final parameter
| public void TakeExperience(long amount, bool enableLevelDown = false) | ||
| { | ||
| if (this is Player && Options.Instance.Map.DisableExpLossInArenaMaps && Map.ZoneType == MapZone.Arena) | ||
| if (Options.Instance.Map.DisableExpLossInArenaMaps && Map.ZoneType == MapZone.Arena) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to if (force || (Options.Instance.Map.DisableExpLossInArenaMaps && Map.ZoneType == MapZone.Arena))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Events taking experience should not be stopped by map type
| } | ||
| else if (quantity < 0) | ||
| { | ||
| player.TakeExperience(Math.Abs(quantity), command.EnableLevelDown); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add , force: true to the end of the args
a189c03 to
b9cd717
Compare
resolves #2491
Intersect_Client_nSBWzaJB3i.mp4